package com.atguigu1.core.action

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}


/**
 *
 * @description: 行动算子案例
 * @time: 2021-03-12 11:45
 * @author: baojinlong
 **/
object Spark06SaveAction {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("rdd")
    // 设置rdd分区数字
    val sparkContext = new SparkContext(conf)
    val rddValue: RDD[(String, Int)] = sparkContext.makeRDD(Seq(("a", 1)), numSlices = 2)
    rddValue.saveAsTextFile("output1")
    rddValue.saveAsObjectFile("output2")
    // 注意只有K,V才能使用下面算子
    rddValue.saveAsSequenceFile("output3")
    sparkContext.stop()
  }
}
